package com.beiing.tianshuai.tianshuai.mine.presenter;

import com.beiing.tianshuai.tianshuai.base.BasePresenter;
import com.beiing.tianshuai.tianshuai.entity.CommonBean;
import com.beiing.tianshuai.tianshuai.entity.FollowResultBean;
import com.beiing.tianshuai.tianshuai.entity.PersonalDynamicBean;
import com.beiing.tianshuai.tianshuai.entity.PersonalInfoBean;
import com.beiing.tianshuai.tianshuai.mine.model.NewPersonalIndexModel;
import com.beiing.tianshuai.tianshuai.mine.model.NewPersonalIndexModelImpl;
import com.beiing.tianshuai.tianshuai.mine.view.NewPersonalIndexViewImpl;

/**
 * Created by Administrator on 2017/12/21 0021.
 */

public class NewPersonalIndexPresenter extends BasePresenter implements NewPersonalIndexPresenterImpl, NewPersonalIndexModel.OnPersonalIndexRequestListener {

    private NewPersonalIndexViewImpl mView;
    private NewPersonalIndexModelImpl mModel;

    public NewPersonalIndexPresenter(NewPersonalIndexViewImpl view) {
        mView = view;
        mModel = new NewPersonalIndexModel(this);
    }

    @Override
    public void getPersonalDynamicResult(String uid, String id, int lastItemNum, int pageSize) {
        mView.showProgress();
        mModel.getPersonalDynamicResult(uid, id, lastItemNum, pageSize);
    }

    @Override
    public void getUserInfo(String uid, String toId) {
        mModel.getUserInfo(uid, toId);
    }

    @Override
    public void deleteRelay(String uid, String idOne, int position) {
        mModel.deleteRelay(uid, idOne, position);
    }

    @Override
    public void deleteDynamic(String uid, String idOne, int position) {
        mModel.deleteDynamic(uid, idOne, position);
    }

    @Override
    public void setLikeState(String uid, String aid, String toUid) {
        mModel.setLikeState(uid, aid, toUid);
    }

    @Override
    public void setFollowed(String uid, String toUid) {
        mModel.setFollowed(uid, toUid);
    }

    @Override
    public void getPersonalInfoSuccess(PersonalInfoBean bean) {
        mView.onRequestSuccess(bean);
    }

    @Override
    public void getPersonalInfoError(Throwable throwable) {
        mView.onRequestFailed(throwable);
    }

    @Override
    public void getPersonalDynamicSuccess(PersonalDynamicBean bean) {
        mView.hideProgress();
        mView.getDynamicsSuccess(bean);
    }

    @Override
    public void getPersonalDynamicError(Throwable throwable) {
        mView.hideProgress();
        mView.getDynamicsError(throwable);
    }

    @Override
    public void onDelDynamicSuccess(CommonBean bean, int position) {
        mView.onDelDynamicSuccess(bean, position);
    }

    @Override
    public void onDelDynamicError(Throwable throwable) {
        mView.onDelDynamicError(throwable);
    }

    @Override
    public void onFollowSuccess(FollowResultBean bean) {
        mView.onFollowSuccess(bean);
    }

    @Override
    public void onFollowError(Throwable throwable) {
        mView.onFollowError(throwable);
    }
}
